// EONumber.cs created with MonoDevelop
// User: awilliam at 1:31 PM 9/25/2008
//
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
//

using System;

namespace Whitemice.EOMono
{
  public class EONumber : EOValue
  {
    protected double val;
    
    public EONumber() : base()
    {
    }
    
    public EONumber(double val) : base()
    {
      this.Value = val;
    }
    
    public EONumber(EONumber val) : base()
    {
      this.Value = val.Value;
    }
    
    public override object Value
    {
      get 
      { 
        if (this.HasValue) return val; 
        throw new EONullValueException();
      }
      set 
      { 
        this.HasValue = true;
        val = Convert.ToDouble(value); 
      }
    }
    
    public override string SQLValue()
    {
      if (IsNull)  return "NULL";
      return val.ToString();
    }
  }
}
